<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LINE 1 &quot;libraries\\Win32\\System\\Win32\\Console\\Title.hsc&quot; #-}</span><span>
</span><span id="line-1"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-comment">{- |
   Module      :  System.Win32.Console.Title
   Copyright   :  2013 shelarcy
   License     :  BSD-style

   Maintainer  :  shelarcy@gmail.com
   Stability   :  Provisional
   Portability :  Non-portable (Win32 API)

   Get/Set the title for the current console window.
-}</span><span>
</span><span id="line-13"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Win32.Console.Title</span><span>
</span><span id="line-14"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">getConsoleTitle</span><span>
</span><span id="line-15"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">setConsoleTitle</span><span>
</span><span id="line-16"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-17"></span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.String</span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">LPTSTR</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LPCTSTR</span><span>
</span><span id="line-19"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">withTStringBufferLen</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">withTString</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">peekTStringLen</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span>  </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">BOOL</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">failIfFalse_</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">failIfZero</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Word</span><span>   </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-special">)</span><span class="hs-cpp">


#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-26"></span><span class="hs-identifier">getConsoleTitle</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-27"></span><span class="hs-identifier">getConsoleTitle</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-28"></span><span>  </span><span class="hs-identifier">withTStringBufferLen</span><span> </span><span class="hs-identifier">maxLength</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-29"></span><span>      </span><span class="hs-identifier">len'</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">failIfZero</span><span> </span><span class="hs-string">&quot;GetConsoleTitle&quot;</span><span>
</span><span id="line-30"></span><span>        </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetConsoleTitle</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">len</span><span class="hs-special">)</span><span>
</span><span id="line-31"></span><span>      </span><span class="hs-identifier">peekTStringLen</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">buf</span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">fromIntegral</span><span> </span><span class="hs-identifier">len'</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-33"></span><span>    </span><span class="hs-identifier">maxLength</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">260</span><span>
</span><span id="line-34"></span><span class="hs-pragma">{-# LINE 34 &quot;libraries\\Win32\\System\\Win32\\Console\\Title.hsc&quot; #-}</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-identifier">setConsoleTitle</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span class="hs-identifier">setConsoleTitle</span><span> </span><span class="hs-identifier">title</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-37"></span><span>  </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-identifier">title</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-38"></span><span>      </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">unwords</span><span> </span><span class="hs-special">[</span><span class="hs-string">&quot;SetConsoleTitle&quot;</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">title</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span>        </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_SetConsoleTitle</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h GetConsoleTitleW&quot;</span><span>
</span><span id="line-42"></span><span>  </span><span class="hs-identifier">c_GetConsoleTitle</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-string">&quot;windows.h SetConsoleTitleW&quot;</span><span>
</span><span id="line-45"></span><span>  </span><span class="hs-identifier">c_SetConsoleTitle</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPCTSTR</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span></pre></body></html>